<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
         for(var r=1;r<25;r++){
    for(var w=1;w<25;w++){
        for(var b=1;b<28;b++){
            if(r+w == 25 && r+b == 28 && w+b == 31) {      
                alert("red:"+r+"\n"+"black:"+b+"\n"+"white:"+w);
                console.log("red:"+r+"\n"+"black:"+b+"\n"+"white:"+w);
                break;
            }
        }
    }
}
    </script>
</body>
</html>